package game;

import game.CardName;
import static game.CardName.*;

public class CardFactory {
	
	public static final String CREATURE = "CREATURE";
	public static final String LAND = "LAND";
	public static final String INSTANT = "INSTANT"; // TODO: make enums
	
	public static Card makeCard(CardName name) {
		
		switch(name) {
		case MOUNTAIN:
				return makeMountain();
		case LIGHTNING_BOLT:
				return makeLightningBolt();
		case BALL_LIGHTNING:
				return makeBallLightning();
		case FAKE_ONE_ONE:
				return makeFakeOneOneCreature();
		case FAKE_TWO_TWO:
				return makeFakeTwoTwoCreature();
		case GOBLIN_GUIDE:
				return makeGoblinGuide();
		case HELLS_THUNDER:
				return makeHellsThunder();
		case HELLSPARK_ELEMENTAL:
				return makeHellsparkElemental();
		case TEETERING_PEAKS:
				return makeTeeteringPeaks();
		case SEARING_BLAZE:
				return makeSearingBlaze();
		case JACKAL_FAMILIAR:
				return makeJackalFamiliar();
		case BURST_LIGHTNING:
				return makeBurstLightning();
		case ARID_MESA:
				return makeAridMesa();
		case SCALDING_TARN:
				return makeScaldingTarn();
		case FLAME_JAVELIN:
				return makeFlameJavelin();
		default:
				throw new RuntimeException(name + " is invalid");
		}
		
	}
	
	private static Card makeScaldingTarn() {
		Card c = new Card(CardName.SCALDING_TARN.toString(), LAND, 0);
		c.setSacLand(true);
		return c;
	}

	private static Card makeAridMesa() {
		Card c = new Card(CardName.ARID_MESA.toString(), LAND, 0);
		c.setSacLand(true);
		return c;		
	}

	private static Card makeMountain() {
		Card mountain = new Card("Mountain", LAND, 0);
		return mountain;
	}

	private static Card makeLightningBolt() {
		Card lightningBolt = new Card("Lightning Bolt", INSTANT, 1);
		lightningBolt.setDamage(3);  // TODO: switch back to 3
		return lightningBolt;
	}

	private static Card makeGoblinGuide() {
		Card goblinGuide = new Card("Goblin Guide", CREATURE, 1);
		goblinGuide.setPower(2);
		goblinGuide.setToughness(2);
		goblinGuide.setHasHaste(true);
		return goblinGuide;
	}

	private static Card makeFakeOneOneCreature() {
		Card fake = new Card("Fake 1/1", CREATURE, 1);
		fake.setPower(1);
		fake.setToughness(1);
		return fake;
	}
	
	private static Card makeFakeTwoTwoCreature() {
		Card fake = new Card("Fake 2/2", CREATURE, 1);
		fake.setPower(2);
		fake.setToughness(2);
		return fake;
	}
	
	private static Card makeBallLightning() {
		Card c = new Card("Ball Lightning", CREATURE, 3);
		c.setPower(6);
		c.setToughness(1); 
		c.setTrample(true);
		c.setRemoveAtEndOfTurn(true);
		c.setHasHaste(true);
		return c;
	}	
	
	private static Card makeHellsThunder() {
		Card c = new Card("Hell's Thunder", CREATURE, 3);
		c.setPower(4);
		c.setToughness(4);
		c.setRemoveAtEndOfTurn(true);
		c.setFlying(true);
		c.setUnearthCost(5);
		c.setHasHaste(true);	
		return c;
	}
	
	private static Card makeHellsparkElemental() {
		Card c = new Card("Hellspark Elemental", CREATURE, 2);
		c.setPower(3);
		c.setToughness(1);
		c.setRemoveAtEndOfTurn(true);
		c.setTrample(true);
		c.setUnearthCost(2);
		c.setHasHaste(true);
		return c;
	}
	
	private static Card makeTeeteringPeaks() {
		Card c = new Card("Teetering Peaks", LAND, 0);
		return c;
	}

	private static Card makeSacLand() {
		Card c = new Card("Sac Land", LAND, 0);
		return c;
	}

	private static Card makeSearingBlaze() {
		Card c = new Card("Searing Blaze", INSTANT, 2); 
		c.setDamage(3); // this is a weird card - needs to be able to handle landfall etc too
		// for now, going to set it to 3 on the assumption that we can bolt one of our own creatures
		// I added special code in the Game class to handle this card for now
		// TODO: need to fully implement this
		return c;
	}
	
	private static Card makeJackalFamiliar() {
		Card c = new Card("Jackal Familiar", CREATURE, 1);
		c.setPower(2);
		c.setToughness(2);
		c.setCanOnlyAttackWithOtherCreatures(true); // cannot be the sole attacker
		return c;
	}
	
	private static Card makeBurstLightning() {
		Card c = new Card("Burst Lightning", INSTANT, 1);
		c.setDamage(2);
		c.setHasKicker(true);
		c.setKickerCost(4); // i.e. 5 in total
		c.setDamageWithKicker(4);
		return c;
	}
	
	private static Card makeFlameJavelin() {
		Card c = new Card(FLAME_JAVELIN.toString(), INSTANT, 3);
		c.setDamage(3);
		return c;
	}
	
}
